# -*- coding: utf-8 -*-
# standard
import os
import sys

# third
from huey import SqliteHuey

# local
_P_PATH =  os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if _P_PATH not in sys.path:
    sys.path.append(_P_PATH)
from models.base_model import *


"""
@Title:   
@File: huey_tasks.py
@Author: walle 2025年01日19日 02时11分31秒
@Version: 1.0.0
@Desc: 
"""

STORE_dir = os.path.join(_P_PATH, 'huey-data')
if not os.path.exists(STORE_dir):
    os.makedirs(STORE_dir)
FILE_STORE = os.path.join(STORE_dir, 'huey.db')
HUEY = SqliteHuey(filename=FILE_STORE)


@HUEY.task()
def push_task_queue(params):
    """
    把任务放到队列里
    :param params: _description_
    :return: _description_
    """
    result = params.execute_task()
    return result


@HUEY.task()
def async_execute_func(func: Callable, kw: dict):
    """
    异步执行函数
    :param func: _description_
    :param kw: _description_
    :return: _description_
    """
    result = func(**kw)
    return result


if __name__ == '__main__':
    pass